package com.wocai.jrt.orgadmin.product.service.impl;

import java.util.Date;
import java.util.List;

import javax.inject.Inject;
import javax.inject.Named;

import org.joda.time.DateTime;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.wocai.jrt.orgadmin.orders.model.Orders;
import com.wocai.jrt.orgadmin.product.dao.RemindDao;
import com.wocai.jrt.orgadmin.product.model.Product;
import com.wocai.jrt.orgadmin.product.service.spi.RemindService;

/**
 * 到期兑付提醒服务实现
 * @author yinlei
 * @date 2015年12月14日 下午5:54:47
 */
@Named
public class RemindServiceImpl implements RemindService {
	private static final Logger LOGGER = LoggerFactory.getLogger(RemindServiceImpl.class);
	
	@Inject
	private RemindDao remindDao;
	
	@Override
	public List<Product> getRemindList(Product params) {
		List<Product> list = null;
		try {
			DateTime dateTime = new DateTime();
			dateTime = dateTime.plusDays(params.getDuration() + 1);
			
			Date date = dateTime.toDate();
			params.setCreateEndTime(date);
			list = remindDao.getRemindList(params);
		} catch (Exception e) {
			LOGGER.error("query cashed remind error, msg=[{}].", e);
		}
		return list;
	}

	@Override
	public Integer getRemindListCount(Product params) {
		return remindDao.getRemindListCount(params);
	}

	@Override
	public List<Orders> getRemindDetailList(Orders params) {
		return remindDao.getRemindDetailList(params);
	}

	@Override
	public Integer getRemindDetailListCount(Orders params) {
		return remindDao.getRemindDetailListCount(params);
	}

}
